# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=whatwaf
pkgver=398.06c815a
pkgrel=5
pkgdesc='Detect and bypass web application firewalls and protection systems.'
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner')
arch=('any')
url='https://github.com/Ekultek/WhatWaf'
license=('BSD')
depends=('python' 'python-beautifulsoup4' 'python-requests')
makedepends=('git')
source=("$pkgname::git+https://github.com/Ekultek/WhatWaf.git"
        '__init__.py.patch')
sha512sums=('SKIP'
            '1504f5c79f3d5de6225aeb1733dfb2faa031d59c8096d15272f64d337d5603bdccd5896ffa4e184310c170f7b6d83e4f5159d4ce3b90548e5ef759f2f0b465a1')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  patch content/__init__.py "$srcdir/__init__.py.patch"

}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm *.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/$pkgname"
}

